﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace DoAn
{
    public abstract class VisibleGameEntity : GameEntity
    {
        public List<MySprite> mySprites;
        private MySprite _SpriteModel;

        public MySprite SpriteModel
        {
            get { return _SpriteModel; }
            set { _SpriteModel = value; }
        }

        
        protected int _nSprites;
        public int nSprites
        {
            get { return _nSprites; }
            set { _nSprites = value; }
        }

        public Vector2 _topleft;
        virtual public Vector2 Topleft
        {
            get
            {
                return _topleft;
            }
            set
            {
                _topleft = value;
                //for (int i = 0; i < nSprites; i++)
                //{
                //    mySprites[i].Position = _topleft;
                //}
            }
        }


        protected Vector2 _size;
        public Vector2 Size
        {
            get { return _size; }
            set 
            { 
                _size = value;
                for (int i = 0; i < nSprites; i++)
                {
                    mySprites[i].Size = Size;
                }
            }
        }




        virtual public void Update(GameTime gameTime)
        {
            for (int i = 0; i < nSprites; i++ )
            {
                mySprites[i].Update(gameTime);
            }
        }


        //virtual public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        //{
        //    for (int i = 0; i < nSprites; i++)
        //    {
        //        Rectangle rect = new Rectangle((int)mySprites[i].Position.X, (int)mySprites[i].Position.Y, (int)Size.X, (int)Size.Y);
        //        mySprites[i].Draw(gameTime, spriteBatch);
        //    }
        //}

        virtual public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            for (int i = 0; i < nSprites; i++)
            {
                Rectangle rect = new Rectangle((int)Topleft.X, (int)Topleft.Y, (int)Size.X, (int)Size.Y);
                mySprites[i].Draw(gameTime, spriteBatch, rect);
            }
        }


        
    }
}
